define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'company_job/index' + location.search,
                    add_url: 'company_job/add',
                    edit_url: 'company_job/edit',
                    del_url: 'company_job/del',
                    multi_url: 'company_job/multi',
                    table: 'company_job',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'jobname', title: __('Jobname')},
                        {field: 'job_class_id_text', title: __('Job_class_id_text')},
                        {field: 'job_class_id', title: __('Job_class_id')},
                        {field: 'job_industry_id_text', title: __('Job_industry_id_text')},
                        {field: 'job_industry_id', title: __('Job_industry_id')},
                        {field: 'job_citystr', title: __('Job_citystr')},
                        {field: 'job_provicecode', title: __('Job_provicecode')},
                        {field: 'job_provicecodestr', title: __('Job_provicecodestr')},
                        {field: 'job_citycode', title: __('Job_citycode')},
                        {field: 'job_citycodestr', title: __('Job_citycodestr')},
                        {field: 'job_areacode', title: __('Job_areacode')},
                        {field: 'job_areacodestr', title: __('Job_areacodestr')},
                        {field: 'edu_type', title: __('Edu_type')},
                        {field: 'work_year', title: __('Work_year')},
                        {field: 'ability_tag', title: __('Ability_tag')},
                        {field: 'salary_start_id', title: __('Salary_start_id')},
                        {field: 'salary_end_id', title: __('Salary_end_id')},
                        {field: 'work_type_id', title: __('Work_type_id')},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});